2024 Daiichi DS-1062a

Report: 30342

## load required packages
library(Seurat)
library(cowplot)
library(dplyr)
library(ggplot2)
library(DT)
library(paletteer)
library(forcats)


dir= "~/Desktop/DF/DFCI_Paweletz/2024_Daiichi_DXD/"
obj.srt = readRDS(paste0(dir,"rds/P30342.24.06.23.CancerCellSubset.rds"))

Cancer Cells population

Cancer Cells Subset (UMAP)

orig.ident_fils = paletteer::scale_fill_paletteer_d("ggsci::nrc_npg") 
DimPlot(obj.srt, group.by = "orig.ident", pt.size = 0.2) + theme_bw() +
  ggtitle("T Cells")

Cancer Cells Subset (UMAP in split)

DimPlot(obj.srt, group.by = "orig.ident", pt.size = 0.1) + theme_bw() +
  ggtitle("Cancer Cells") + facet_wrap(.~orig.ident, ncol=2)

orig.ident_fils = paletteer::scale_fill_paletteer_d("ggsci::nrc_npg") 

Number of Cancer Cells

res = "orig.ident"
obj.srt@meta.data %>% ggplot(aes(!!sym(res), fill=!!sym(res))) + 
  geom_bar(alpha=0.7, color="grey5", size=0.1) +
  geom_text(stat="count", aes(label= ..count..), vjust=-0.5, size=3) +
  orig.ident_fils + 
  xlab("") + 
  theme_classic() +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, hjust=1)) 

Clustering

  • resolution 0.2
  • resolution 0.4
resolution_values <- c(0.2, 0.4)

Resolution 0.2 UMAP

# Resolution and color palette
i=1
res= paste0("RNA_snn_res.", resolution_values[i])
palette <- wesanderson::wes_palette("FantasticFox1", length(levels(obj.srt@meta.data[,res])), type = "continuous")
DimPlot(obj.srt, group.by = res, cols = palette, alpha = 0.8) + 
  theme(plot.title = element_blank()) + xlab("UMAP1") + ylab("UMAP2")

Resolution 0.2 UMAP (label)

DimPlot(obj.srt, group.by = res, alpha = 0.8,
        label = T, label.box = T, label.size = 3, cols = palette) + theme(plot.title = element_blank())

Cell numbers

obj.srt@meta.data %>% ggplot(aes(!!sym(res), fill=!!sym(res))) + 
  geom_bar(alpha=0.7, color="grey5", size=0.1) +
  geom_text(stat="count", aes(label= ..count..), vjust=-0.5, size=3) +
  scale_fill_manual(values=palette) + 
  xlab("") + 
  theme_classic() +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust=0.5)) +
  ggtitle("Cluster")

Proportion by cluster

obj.srt@meta.data %>% ggplot(aes(!!sym(res), fill=orig.ident)) + 
  geom_bar(position = "fill", color="grey9",size = 0.2, alpha=0.8) + scale_fill_paletteer_d("ggsci::nrc_npg") + theme_classic()+ 
  theme(legend.title = element_blank()) +
  ylab("Fraction")

Resolution 0.4 UMAP

# Resolution and color palette
i=2
res= paste0("RNA_snn_res.", resolution_values[i])
palette <- wesanderson::wes_palette("FantasticFox1", length(levels(obj.srt@meta.data[,res])), type = "continuous")
DimPlot(obj.srt, group.by = res, cols = palette, alpha = 0.8) + 
  theme(plot.title = element_blank()) + xlab("UMAP1") + ylab("UMAP2")

Resolution 0.4 UMAP (label)

DimPlot(obj.srt, group.by = res, alpha = 0.8,
        label = T, label.box = T, label.size = 3, cols = palette) + theme(plot.title = element_blank())

Cell numbers

obj.srt@meta.data %>% ggplot(aes(!!sym(res), fill=!!sym(res))) + 
  geom_bar(alpha=0.7, color="grey5", size=0.1) +
  geom_text(stat="count", aes(label= ..count..), vjust=-0.5, size=3) +
  scale_fill_manual(values=palette) + 
  xlab("") + 
  theme_classic() +
  theme(legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust=0.5)) +
  ggtitle("Cluster")

Proportion by cluster

obj.srt@meta.data %>% ggplot(aes(!!sym(res), fill=orig.ident)) + 
  geom_bar(position = "fill", color="grey9",size = 0.2, alpha=0.8) + scale_fill_paletteer_d("ggsci::nrc_npg") + theme_classic()+ 
  theme(legend.title = element_blank()) +
  ylab("Fraction")

Sankey plot

## sankey plot 
library(ggsankey)
library(ggplot2)
library(dplyr)

cols = c('orig.ident','RNA_snn_res.0.2','RNA_snn_res.0.4')
data =obj.srt@meta.data[, cols]
data[,cols[2]] = paste0("res0.2_", data[,cols[2]])
data[,cols[3]] = paste0("res0.4_", data[,cols[3]])

sankey_plot = function(data = data){
  # Function to create a Sankey plot
  df <- data %>%
    make_long(!!cols[1], !!cols[2], !!cols[3])
  
  dagg <- df %>%
    group_by(node) %>%
    tally()
  
  df2 <- merge(df, dagg, by.x = 'node', by.y = 'node', all.x = TRUE)
  
  pl <- ggplot(df2, aes(x = x,
                        next_x = next_x,
                        node = node,
                        next_node = next_node,
                        fill = factor(node),
                        label = paste0(node," n=", n))
  )
  
  show_labels = "TRUE"
  pl <- pl + geom_sankey(flow.alpha = 0.5, color = "gray40", show.legend = show_labels)
  pl <- pl + geom_sankey_label(size = 3, color = "white", fill = "gray40", hjust = 1) +
    theme_bw() +
    theme(axis.title = element_blank(),
          axis.text.y = element_blank(),
          axis.ticks = element_blank(),
          panel.grid = element_blank()) +
    xlab("") +
    labs(fill = 'Nodes')
  return(pl)
}
# Display the plot
sankey_plot(data = data)

Markers

  • resolution 0.2
  • resolution 0.4

resolution_values <- c(0.2, 0.4)

Markers (0.2)

Download cluster marker file

resolution_number = 0.2
res= paste0("RNA_snn_res.", resolution_number)
mks = read.csv(paste0(dir,"data/mks/30342/Daiichi_30342_Cancersubset_", res, ".markers.csv"), row.names = 1)
len =length(levels(obj.srt@meta.data[,res]))
DT::datatable(mks, editable = TRUE, extensions = "Buttons", options = list(dom="Bfrtip", buttons=c("csv","excel"), pageLength=len))
mks.res02 = mks

Heatmap (res 0.2)

Top 5 genes from each cluster

mks = mks.res02
genes = mks %>% group_by(cluster) %>% top_n(5, avg_log2FC) %>% select(gene) %>% pull()
Idents(obj.srt) = res

i=1
res= paste0("RNA_snn_res.", resolution_values[i])
palette <- wesanderson::wes_palette("FantasticFox1", length(levels(obj.srt@meta.data[,res])), type = "continuous")


DoHeatmap(obj.srt, features = genes, group.colors = palette) +
  viridis::scale_fill_viridis(option="magma") + 
  theme(axis.title.x.top = element_text(size = 4))

Markers (0.4)

Download cluster marker file

resolution_number = 0.4
res= paste0("RNA_snn_res.", resolution_number)
mks = read.csv(paste0(dir,"data/mks/30342/Daiichi_30342_Cancersubset_", res, ".markers.csv"), row.names = 1)
len =length(levels(obj.srt@meta.data[,res]))
DT::datatable(mks, editable = TRUE, extensions = "Buttons", options = list(dom="Bfrtip", buttons=c("csv","excel"), pageLength=len))
mks.res04 = mks

Heatmap (res 0.4)

Top 5 genes from each cluster

mks = mks.res04
genes = mks %>% group_by(cluster) %>% top_n(5, avg_log2FC) %>% select(gene) %>% pull()
Idents(obj.srt) = res

i=2
res= paste0("RNA_snn_res.", resolution_values[i])
palette <- wesanderson::wes_palette("FantasticFox1", length(levels(obj.srt@meta.data[,res])), type = "continuous")


DoHeatmap(obj.srt, features = genes, group.colors = palette) +
  viridis::scale_fill_viridis(option="magma") + 
  theme(axis.title.x.top = element_text(size = 4))